Data storage device and control method with buffer control thereof

ABSTRACT

Embodiments of the invention improve the cache hit ratio of read data. A hard disk drive (HDD) according to an embodiment of the present invention determines whether the read buffer should be used in its entirety or the partial continuous space should be used to read read-data from the magnetic disk. When the HDD determines use of the partial continuous space, the HDD specifies the sub-buffer which is a continuous space wherein the leading-end position and the trailing-end position are coupled to each other, and executes data writing to the sub-buffer in parallel with data reading from the sub-buffer and transmission thereof to the host. The sub-buffer capacity coincides with the data length of the back data.

CROSS-REFERENCES TO RELATED APPLICATIONS

This application claims priority from Japanese Patent Application No.JP2004-377827, filed Dec. 27, 2004, the entire disclosure of which isincorporated herein by reference.

BACKGROUND OF THE INVENTION

The present invention relates to a data storage device, and morespecifically to a buffer control method in a data storage device.

Data storage devices using various types of media such as optical disks,magnetic tapes and semiconductor memories are known in the art. Amongthem, hard disk drives (hereinafter referred to as HDDs) have becomepopular as storage devices for computers to such an extent that they areone type of the storage devices indispensable for today's computers.Further, not limited to computer systems, HDDs are expanding more andmore in application because of its excellent characteristics. Forexample, HDDs are used for moving picture recording/reproducing devices,car navigation systems, cellular phones, and removable memories for usein digital cameras.

Each magnetic disk used in HDDs has a plurality of tracks formedconcentrically and each track is partitioned into a plurality ofsectors. Sector address information and user data are stored in eachsector. Either data write to a sector or data read from the sector isenabled by a magnetic head which accesses the desired sector accordingto the sector address information. In a data read operation, a signalread out by the head from a magnetic disk is subjected to waveformshaping, decoding processing and other prescribed signal processing by asignal processing circuit before being transmitted to the host.Likewise, data transferred from the host is subjected to prescribedsignal processing by the signal processing circuit and then written tothe magnetic disk.

Read data that is read from the magnetic disk is temporarily stored in abuffer before being transmitted to the host. In the buffer, data thatwas read from the magnetic disk in the past is stored, and when datarequired from the host is cached in the buffer, the data stored in thebuffer is transmitted to the host without making an access to themagnetic disk. With such arrangement, it is possible to improveperformance of the HDD.

Several methods related to buffer control of read data have been knownfor improving the HDD performance. One of the methods is disclosed inPatent Document 1 (Japanese Patent Laid-Open No. 2003-122631), whereinan HDD includes a data buffer comprising a main memory and an auxiliarymemory to store read or written data. At the time of initialization,data of a specified sector such as an alternating process accompanying aseek operation will be read into the auxiliary memory in advance. Withsuch arrangement, HDD performance can be improved.

BRIEF SUMMARY OF THE INVENTION

As technologies to buffer read data, a technology using a ring bufferhas been known in the art. An HDD stores data read from a magnetic diskin the ring buffer one by one in a time-series order. When the buffer isused up to the trailing position, the leading position of the buffer isresumed. HDDs that have been known so far include an HDD in which a ringbuffer stores both of read and write data, and an HDD which incorporatesan independent ring buffer for storing read data and an independent ringbuffer for storing write data.

For a case where write data and read data are stored in a ring buffer,however, when a read command having a data length exceeding the size ofa free space is received, for the purpose of preventing erasure of writedata, it is not possible to execute a read process until writing of thewrite data to the magnetic disk is completed. Otherwise, in an HDD whichincludes respective different buffers for reading and writing data, whena read command requesting read data having a sizable data length isissued, much of cache data existing in the buffer will be overwritten.Further, since the transmitted data is cached in the host, the HDDbuffer will cache data that is redundant with the cache data in thehost. Consequently, the cache hit rate to the read command from the hostwill decrease, thus resulting in deteriorated performance of the HDD.

The present invention has been achieved in view of the above-describedbackground, and a feature of the invention is to improve the cache hitrate of read data in a buffer of a data storage device.

According to a first aspect of the present invention, there is provideda data storage device that transmits read data read from a recordingmedium to a host. The data storage device comprises: a buffer having aleading end and a trailing end coupled to each other and enablingcontinuous recording of data from a write start position designated by apointer; and a controller for controlling data recording to the buffer.The controller determines whether the buffer should be used as a wholeor part of continuous space of the buffer should be used to read theread data from the recording medium; specifies, if using the part ofcontinuous space is determined, a sub-buffer which is a continuous spaceformed by coupling a leading-end position and a trailing-end position toeach other; and executes writing of data from the recording disk to thesub-buffer in parallel with reading of the read data to the host. Withthe arrangement to select use of the buffer as a whole or use of partialspace, it is possible to improve the cache hit rate.

Consistency of the sub-buffer and the part of continuous space forms afavorable mode. By achieving the aspect, it is possible to reduce theamount of existing cache data to be overwritten and erased in thebuffer. Further, referring to the data storage device of the firstembodiment, it is preferable that the data to be read from the recordingmedium contains, in addition to read data to the host, back data that isstored in the back position of the read data in the recording medium,and the capacity of the sub-buffer coincides with the data length of theback data. With such an arrangement, it is possible to reduce the amountof existing cache data to be erased and leave and keep the back data ascache data.

It is preferable that the data to be read from the recording mediumcontain, in addition to read data to the host, back data that is storedin the back position of the read data in the recording medium, and thecapacity of the sub-buffer is smaller than data to be read from therecording medium and is larger than the data length of the back data.With such an arrangement, it is possible to leave and keep the back dataas cache data.

It is preferable that the data to be read from the recording mediumcontain, in addition to read data to the host, back data that is storedin the back position of the read data in the recording medium, and thatthe capacity of the sub-buffer coincide with the data length of the backdata. With such an arrangement, it is possible to leave and keep theback data as cache data.

It is preferable that the data to be read from the recording mediumcontain, in addition to read data to the host, back data that is storedin succession to the back position of the read data in the recordingmedium as well as the front data that is stored in the front position ofthe read data in the recording medium, that the capacity of thesub-buffer exceed the data length of the back data, and that the frontdata be written in the front space of the sub-buffer and the back databe written after writing the read data in the sub-buffer. With such anarrangement, it is possible to leave and keep the front data and theback data as cache data.

From the view point of performance, it is preferable that the datastorage device include a write buffer to store write data from the host,in addition to the above-stated buffer to store data from the recordingdisk.

It is preferable that the controller be designed to determine to use thepartial continuous space when the expected data length of data to beread from the recording medium is larger than a reference value. Inaddition, in terms of achieving control according to data length, it ispreferable that the reference value be a predetermined fixed value andthe value be chosen among values indicating about 50% or over of theread buffer capacity. Using the partial continuous space when the datalength is sizable enables to avoid much of the existing cache data frombeing erased.

It is preferable that the controller be designed to determine to use thepartial continuous space when the expected data length of data to beread from the recording medium is larger than the read buffer capacity.With such an arrangement, it is possible to avoid all the existing cachedata from being erased.

The controller determines to use the partial continuous space when theexpected data length of data read from the recording medium is largerthan the capacity of the continuous free space located next to the endposition of previous data writing to the read buffer and the data lengthis larger than the reference value. With such an arrangement, it ispossible to avoid much of the existing cache data from being erased.

It is preferable that the controller be designed to use the fact thatthe command associated with the read data is sequential read as one ofcriteria for determining the use of partial continuous space in the readbuffer. With such an arrangement, it is possible to leave and keep dataother than the data transmitted to the host as cache data.

It is preferable to design that the data storage device reads the backdata stored in the back position of the read data in the recordingmedium together with the read data to be transmitted to the host fromthe recording disk, and that the controller determines, when at leastpart of read data of sequential read is not contained in the back dataat the time of previous data reading from the recording disk, to use thepartial continuous space in the read buffer for reading the read data ofthe sequential read from the recording disk. With such an arrangement,it is possible to leave and keep data other than the data transmitted tothe host as cache data.

According to another aspect of the present invention, there is provideda control method of a data storage device which includes a buffer havinga leading end and a trailing end coupled to each other and enablingcontinuous recording of data from a write start position as designatedby a pointer. The method comprises the steps of: receiving a readcommand from a host; determining reading read data associated with theread command from a recording medium; determining whether the buffershould be used as a whole or part of continuous space in the buffershould be used to store data, including the read data, read from therecording medium; writing data, when it is determined to use the partialcontinuous space, from the recording medium to a sub-buffer which is acontinuous space formed by coupling a leading-end position and atrailing-end position to each other as defined within the partialcontinuous space; and in parallel with the data writing to thesub-buffer, reading the read data from the sub-buffer to the host. Bychoosing use of the buffer as a whole or use part of the buffer, it ispossible to improve the cache hit rate.

It is preferable, based on the data length of data to be read from therecording medium, to determine that the buffer is used as a whole or thepartial continuous space in the read buffer is used. By choosing data tobe kept as cache data according to data length, it is possible toimprove the cache hit rate.

It is preferable that the data to be read from the recording mediumshould contain, in addition to the read data to the host, back datastored in the back position of the read data in the recording medium,and that the capacity of the sub-buffer should coincide with the datalength of the back data. With such an arrangement, it is possible toleave and keep the back data as cache data and to reduce the amount ofexisting cache data to be erased.

It is preferable that the data to be read from the recording mediumshould contain, in addition to the read data to the host, the back datastored in the back position of the read data in the recording medium andthe front data stored in the front position of the read data in therecording medium, and that the capacity of the partial continuous spaceshould be at least a value which is the sum of the data length of theback data and the data length of the front data. With such anarrangement, it is possible to leave and keep the back data and thefront data as cache data.

According to the present invention, it is possible to improve the cachehit rate of read data in a buffer of a data storage device.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram showing a schematic overall configuration ofan HDD according to an embodiment of the invention.

FIG. 2 is a schematic diagram explaining a read buffer according to anembodiment of the invention.

FIG. 3 is a schematic diagram describing a control method for a casewhere a read buffer is used as a whole according to an embodiment of theinvention.

FIG. 4 is a schematic diagram describing a control method for a casewhere partial continuous space of a read buffer is used according toanother embodiment of the invention.

FIG. 5 is a schematic diagram describing another control method for acase where partial continuous space of a read buffer is used accordingto another embodiment of the invention.

FIG. 6 is a flow chart showing a control sequence of a read bufferaccording to an embodiment of the invention.

FIG. 7 is a flow chart showing a control sequence of a read bufferaccording to an embodiment of the invention.

FIG. 8 is a block diagram showing a logical configuration related toread buffer control in an HDD according to an embodiment of theinvention.

FIG. 9 is a diagram showing an example of a cache table for read buffercontrol in an HDD according to an embodiment of the invention.

FIG. 10 is a flow chart showing a control sequence of a read bufferaccording to an embodiment of the invention.

DETAILED DESCRIPTION OF THE INVENTION

Hereinafter, specific embodiments to which the present invention isapplicable will be described. To clearly articulate the description,descriptions and drawings stated hereunder are omitted and simplified asappropriate. It should also be noted that, in the drawings, the samereference numerals are given to the same components, and redundantdescriptions thereof are omitted as required to clearly articulate thedescription.

Hereinafter, specific embodiments to which the present invention isapplied will be described in detail with reference to the accompanyingdrawings. The present invention relates to buffer control in a datastorage device. In the embodiment, the buffer control according to thepresent invention will be described by taking a hard disk drive (HDD)which is one of the data storage device as an example. To make thepresent invention more understandable, outline of the overallconfiguration of the HDD will be described first. FIG. 1 is a blockdiagram showing a schematic configuration of an HDD 1 according to theembodiment. As shown in FIG. 1, the HDD1 includes a magnetic disk 11which is an example of recording media, a head element 12, an armelectronics (AE) 13, a spindle motor (SPM) 14 and a voice coil motor(VCM) 15 within a hermetically-sealed enclosure 10.

The HDD 1 is provided with a circuit board 20 which is fixed on theouter side of the enclosure 10. The circuit board 20 has, thereon, aread/write channel (R/W channel) 21, a motor driver unit 22, a hard diskcontroller (HDC)/MPU integrated circuit (hereinafter referred to asHDC/MPU) 23, a RAM 24 as an example of memories, and other ICs. Itshould be noted that circuit configurations can be integrated into oneIC or can be mounted by dividing the circuit configurations into aplurality of ICs.

Write data from an external host 51 is received by the HDC/MPU 23 and iswritten on the magnetic disk 11 by the head element 12 via the R/Wchannel 21 and the AE 13. Further, read data stored on the magnetic disk11 is read by the head element 12, and the data thus read is output tothe external host 51 from the HDC/MPU 23 via the AE 13 and the R/Wchannel 21.

Next, each component of the HDD 1 will be described. The magnetic disk11 is fixed on the SPM 14. The SPM 14 rotates the magnetic disk 11 at aprescribed speed. The motor driver unit 22 drives the SPM 14 accordingto control data from the HDC/MPU 23. The magnetic disk 11 of theembodiment is provided on both sides thereof with recording surfaces onwhich data are recorded. The head elements 12 are provided to beassociated with the respective recording surfaces.

Each head element 12 is fixed on a slider (not shown in FIG. 1).Further, the slider is fixed on an actuator. The actuator is coupled tothe VCM 15, and the actuator is turned around its rotating axis to movethe head elements 12 in a radial direction on the magnetic disk 11. Themotor driver unit 22 drives the VCM 15 according to control data fromthe HDC/MPU 23.

Typically, a write head which converts electric signals to magneticfields according to write data to be stored on the magnetic disk 11 anda read head which converts magnetic fields from the magnetic disk 11 toelectric signals are formed on the head elements 12 as an integral part.It should be noted that at least one magnetic disk 11 is sufficient tobe prepared, and the recording surface can be formed on a single side ordouble sides of the magnetic disk 11.

Next, each circuit will be described. The AE 13 selects one head element12, among a plurality of head elements 12, through which data accessingis executed, amplifies a read signal to be read by the head element 12thus selected at a constant gain (pre-amplifying) and sends the signalto the R/W channel 21. Further, the AE 13 sends a write signal from theR/W channel 21 to the selected head element 12.

The R/W channel 21 executes a write process on the data transferred fromthe host 51. In the write process, the R/W channel 21 executes a codemodulation on the write data supplied by the HDC/MPU 23 and furtherconverts the code-modulated write data into a write signal (current),thereby supplying the signal to the AE 13. Further, when supplying datato the host 51, the R/W channel 21 executes a read process. In the readprocess, the R/W channel 21 amplifies the read signal supplied from theAE 13 so that the signal amplitude can be constant, extracts data out ofthe read signal thus acquired, and executes a decoding process. The datato be read includes user data and servo data. The decoded read data issupplied to the HDC/MPU 23.

The HDC/MPU 23 is a circuit in which an MPU and an HDC are integratedinto one chip. The MPU operates according to micro-codes loaded in theRAM 24, in which, when the HDD 1 starts up, data that is required forcontrol and data processing, in addition to micro-codes that run on theMPU, are loaded from the magnetic disk 11 or a ROM (not shown in FIG.1). The HDC/MPU 23 executes overall control of the HDD 1 in addition toprocesses that are required for data processing such as positioningcontrol of the head element 12, interface control and defect management.

The HDC/MPU 23 transmits read data from the magnetic disk 11 obtainedfrom the R/W channel 21 to the host 51. The read data from the magneticdisk 11 is temporarily stored in a read buffer in the RAM 24 and is thentransferred to the host 51 via the HDC/MPU 23. On the other hand, writedata from the host 51 is temporarily stored in a write buffer in the RAM24 and is then transferred to the magnetic disk 11 with a prescribedtiming via the HDC/MPU 23.

Next, the read buffer control of the HDD 1 according to the embodimentwill be described. The HDD 1 according to the embodiment includes a readbuffer and a write buffer independently. Further, one read buffer dealswith all read data. The HDD 1 performs prefetching and pre-reading whenreading read data associated with a read command (data to be transferredto the host 51) from the magnetic disk 11. More specifically, the HDD 1reads out from the magnetic disk 11 back data (prefetching) that isrecorded after the read data and front data that is recorded before theread data as well as the read data. It should be noted that the frontdata and the back data are typically recorded on the magnetic disk 11 insuccession to the read data.

The HDD 1 determines, based on the data to be read from the magneticdisk 11, whether the read buffer is used as a whole or the partialcontinuous space thereof is used. FIG. 2 shows a read bufferconceptually to describe the read buffer control according to theembodiment. As shown in FIG. 2, a read buffer 241 of the embodiment hasa buffer configuration wherein the leading-end address AD 1 and thetrailing-end address AD 2 thereof are coupled to each other.

The read buffer 241, after storing data read from the magnetic disk 11up to the trailing-end address AD 2, stores the data in succession tothe leading-end address AD 1 from the trailing-end address AD 2. Morespecifically, the read buffer 241 is capable of storing data associatedwith a read command across the trailing-end address AD 2 and theleading-end address AD 1. Here, the data associated with a read commandshall include front data FD and/or back data BD in addition to read dataRD when prefetching and pre-reading is executed. As stated above, bycoupling the leading-end address AD 1 to the trailing-end address AD 2of the read buffer 241, it is possible to use the read buffer 241efficiently.

In addition, the read buffer 241 addresses data in units of sector,which is a data processing unit of the HDD 1, and stores read dataassociated with a read command in a series of continuous addresses. Theread buffer 241 of the embodiment is not divided into a plurality ofsegments but is configured as a continuous section. Therefore, the readbuffer 241 can store data associated with a read command in a continuousfree space which can be started at a random address. By configuring aread buffer in a manner that the buffer is not partitioned by aplurality of segments but forms a continuous section, it is possible toimprove efficiency in using the buffer space.

Writing data to the read buffer 241 is started at an address (position)as directed by a write pointer WP. Likewise, reading of read data RD tothe host 51 is started at an address (position) as directed by a readpointer RP. Here, in conventional read buffer control, since the wholeread buffer was always used as a continuous space, when reading sizabledata from the magnetic disk 11, data that has already been cached in theread buffer is overwritten, which deteriorated the cache hit rate.

In contrast, with the HDD 1 according to the embodiment, data read fromthe magnetic disk 11 is stored by using partial continuous space of aread buffer as required. Further, a sub-buffer constituting a continuousspace by coupling the leading-end position to the trailing-end positionis formed to execute writing of data read from the magnetic disk 11 tothe sub-buffer and reading of read data to the host 51 in parallel toeach other. As stated above, by selecting use of the read buffer 241 asa whole and use of the partial continuous space thereof, it is possibleto realize efficient read buffer control.

FIG. 3 shows a case where the read buffer 241 is used as a whole inresponding to a read command from the host 51. As shown in FIG. 3, dataread from the magnetic disk 11 is written in a space starting from awrite start position AD 3 to a write end position AD 4 as directed bythe write pointer WP. After the writing is completed, the write pointeris set at the write end position AD 4. With the example, in respondingto a read command from the host 51, front data FD and back data BD areread from the magnetic disk 11 in addition to the read data RD.

Data read from the magnetic disk 11 is sequentially recorded from thewrite start position AD 3 to the write end position AD 4 as directed bythe write pointer WP in a manner that addresses will increasecontinuously (toward the right-hand direction of the drawing). It shouldbe noted that, when the recorded data reaches the trailing-end positionAD 2 of the read buffer 241, the data is continued to be recordedstarting at the leading-end position AD 1. The read data RD is stored ina space from an address position AD 5 to an address position AD 6. Theread pointer RP directs the read start position AD 5, and the read dataRD read as directed by the read pointer RD is transferred to the host51. When the sequence is terminated, newly written front data FD, readdata RD and back data BD will remain in the read buffer 241.

FIG. 4 shows an example in which a partial continuous space of the readbuffer 241 is used. With the example in FIG. 4, read data from themagnetic disk 11 is stored in a partial continuous space 411 from aleading-end position AD 7 to a trailing-end position AD 8. In addition,with the embodiment, a sub-buffer 412 is defined so that the sub-bufferwill coincide with the partial continuous space. As stated above, theleading-end position AD 7 and the trailing-end position AD 8 of thesub-buffer 412 are coupled to each other.

The write pointer WP initially designates the leading-end position AD 7of the partial continuous space 411 (and the sub-buffer 412) as thewrite start position. First, front data FD is written in the read buffer241 from a position as directed by the write pointer WP. The front dataFD is written in a space up to an address position AD 9. Thereafter,read data RD is recorded in a space from the address position AD 9 tothe trailing-end position AD 8 of the partial continuous space 411 (andthe sub-buffer 412). It should be noted that, when the data length ofthe read data RD is short, the read data RD is stored in a space up toan address located before the trailing-end position AD 8.

When data is recorded up to the trailing-end position AD 8, data readfrom the magnetic disk 11 is recorded from the leading-end position AD 7of the sub-buffer 412. In this embodiment, the back data BD is recordedin a space from the leading-end position AD 7 to the trailing-endposition AD 8. The read buffer 241 records the back data BD in a mannerto overwrite the front data FD and the read data RD. For this purpose,the HDD 1 executes reading of the read data RD to be transferred to thehost 51 in parallel with writing of data from the magnetic disk 11. Theread pointer RP designates the address position AD 9, thereby startingreading of the read data RD. Then, all read data RD that are recorded ina space from the AD 9 to AD 8 is transferred to the host 51.

As stated above, since the read buffer 241 overwrites the front data FDand the read data RD with the back data BD, the back data BD will bekept as cache data in the read buffer 41. Here, with the example, thesub-buffer capacity coincides with the data length of the back data BD.As a result, all back data BD can be kept as cache data in the readbuffer 241.

The read data RD has already been transferred to the host 51 and cantherefore be cached in the host 51. In this respect, it is unlikely thata command is issued to the HDD 1 regarding the read data RD. Therefore,the read buffer 241 can improve the cache hit rate by storing data otherthan the read data transferred as cache data.

As stated above, by using the sub-buffer 412, the amount of existingcache data that is overwritten and erased by the read data to betransferred to a host can be reduced. With such an arrangement, it ispossible to improve the cache hit rate. Further, since it is possible toleave and keep back data BD not yet transferred to the host 51 in thesub-buffer 412, the cache hit rate can be improved. It should be notedthat, to leave and keep all back data BD, the sub-buffer 412 can havethe size longer than the data length of the back data BD. However, toprevent existing cache data from being erased as much as possible, it ispreferable that the capacity of the sub-buffer 412 should coincide withthe data length of the back data BD. It should also be noted that it ispreferable to leave and keep all back data BD as cache data, but thebuffer control may be designed to leave and keep only part of the backdata BD.

In the example shown in FIG. 4, the partial continuous space 411coincides with the sub-buffer 412. However, the partial continuous space411 may be provided with a space in addition to the space of thesub-buffer 412. FIG. 5 shows a schematic diagram of a read buffer 241which includes a sub-buffer 412 and an additional space 413 in thepartial continuous space 411. The partial continuous space 411 that isselected from the read buffer 241 is secured as a space located betweenaddress positions AD 10 and AD 11. In the partial continuous space 411,the sub-buffer 412 is a space that is clearly defined by addresspositions AD 12 and AD 11. The address position AD 12 corresponds to theleading-end position of the sub-buffer 412, the address position AD 11corresponds to the trailing-end position thereof, and the two positionsare coupled to each other. The additional space 413 is formed in betweenthe address positions AD 10 and AD 12.

When reading data from the magnetic disk 11 is started, the writepointer WP indicates the address position AD 10. Front data FD read fromthe magnetic disk 11 is recorded in the additional space 413 from theaddress position AD 10 to the address position AD 12. Thereafter, readdata RD is recorded in the sub-buffer 412 from the address position AD12. The read data RD is recorded in a space from the address position AD12 to the address position AD 13.

When writing of the read data RD is completed, writing of back data BDis initiated at the address position AD 13. When the back data BD isrecorded up to the trailing-end position AD 11 of the sub-buffer 412(the partial continuous space 411), the back data BD is continuouslyrecorded at the leading-end position AD 12 of the sub-buffer 412. In thespace beyond the address position AD 12, read data has already beenrecorded, which is, however, overwritten with the back data BD.Thereafter, the back data BD is recorded up to the address position AD13. The write pointer WP is temporarily set at the address position AD13, but it will be shifted to the address position AD 11, etc., forexample, to prevent the back data BD from being overwritten with otherdata.

The read data RD is transferred to the host 51 before being overwrittenand erased by the back data BD. The HDD 1 executes reading of the readdata RD from the sub-buffer 412 in parallel with writing of the backdata BD to the sub-buffer 412. Then, the read pointer RP is set at theAD 12, whereby reading of the read data RD is initiated. Thereafter, allread data RD that are stored in the space from the address position AD12 to AD 13 is transferred to the host 51.

The buffer control shown in FIG. 5 shows more complicated control thanthe example shown in FIG. 4, and front data FD will be recorded in theadditional space 413 in addition to the back data BD that is stored inthe sub-buffer 412. As a result, the front data FD can also be kept inthe read buffer 241 as cache data in addition to the back data BD. Here,to leave and keep all back data BD, the additional space 413 can havethe size longer than the data length of the front data FD. However, toprevent existing cache data from being erased as much as possible, it ispreferable that the capacity of the additional space 413 should coincidewith the data length of the front data FD.

The HDD 1 according to the embodiment determines whether the read buffer241 is used as a whole or only the partial continuous space 411 thereofis used. As a preferable judgment criterion, the HDD 1 according to theembodiment determines a method for using the read buffer 241 based onthe data length of data read from the magnetic disk 11 in responding toa read command. The HDD 1, when the data length of data read from themagnetic disk 11 is larger than a reference value, determines to use apartial continuous space. One of the values used for the reference valueis a free space in the read buffer 241. The read buffer 241 will be usedas a whole when a sufficient free space is available in the read buffer241 and the read data from the magnetic disk 11 can be stored therein.

A prescribed fixed value can be used as the reference value. Forexample, it is determined to use a partial continuous space when asufficient free space does not exist and the data length of data to beread is larger than the fixed value. With such an arrangement, it ispossible to leave and keep the existing cache data and improve the cachehit rate.

One of the preferable values is the capacity of the read buffer 241. TheHDD 1 determines to use a partial continuous space when the data lengthof data to be read from the magnetic disk 11 is larger than the wholecapacity of the read buffer 241. Since all existing cache data in theread buffer 241 will be overwritten and erased by the data to be read,it is preferable to leave and keep part of cache data in terms of thecache hit rate. Likewise, it is one of the preferable modes to select afixed value among values indicating about 50% or over of the capacity ofthe read buffer 241. In this case, the HDD 1 can make judgment with afixed value only, or by using both of a free space and a fixed value.More specifically, the HDD 1 can determine to use a partial continuousspace when the data length is larger than the free space and the fixedvalue.

When the data length is smaller than the free space and the fixed value,the read buffer 241 is used as a whole. With such an arrangement, alsoin the case where the control shown in FIG. 4 is carried out, it isensured to leave and keep the front data in the read buffer 241 as cachedata. When the data length of read data is short, it frequently occursthat a request for the front data is made by the host 51 in succession.To this end, by leaving and keeping the front data as cache data, it ispossible to improve the cache hit rate. In addition, when a partialcontinuous space is used like the control as shown in FIG. 5, forexample, the data FD and BD to be cached anew will not be lined up inthe order of LAB. As a result, two or more cache tables will be used forone command, which deteriorates operating efficiency of cache tables.When the data length is short, there is a smaller amount of existingcache data to be overwritten, and it is preferable to use the readbuffer 241 as a whole from the viewpoint of efficient table operations.

Here, data to be read from the magnetic disk 11 includes front data FD,read data RD and back data BD. The front data FD and the back data BDcan be set as a fixed data length or can be made variable according todata length of read data. Usually, the front data FD is read aftercompletion of seek of the read data RD on a recording track. Therefore,when the time from seek completion to arrival of a head to the read dataRD is short, the front data FD will become short. In other words, theHDD 1 is unable to know the data length of the front data FD correctlyat the time of seek start. To this end, the HDD 1 according to theembodiment determines a method for using the read buffer 241 by using anexpected value of data length to be read. It is possible to specify themaximum length of the front data FD to be read, and the maximum length(specified value) can be used as an expected data length of the frontdata FD.

Hereinafter, an example of a process by the HDD 1 to determine a methodof using the read buffer 241 will be described with reference to FIG. 6.In step S11, upon receiving a read command, the HDD 1 judges whether ornot associated read data is stored in the read buffer 241 (cache hitjudgment) (S12). For the case of a cache hit judgment, the HDD 1transfers data in the read buffer 241 to the host 51 (S13).

If the associated read data is not stored in the read buffer 241, theHDD 1 judges whether the expected read data length is larger than thefree space of the read buffer (S14). When the data length is smallerthan the free space, the HDD 1 determines to use the read buffer 241 asa whole (S15). On the other hand, if the HDD 1 judges that the datalength is larger than the free space in step S14, the HDD 1 judgeswhether the data length is larger than a fixed value (fixed referencevalue) such as the buffer capacity (S16). When the data length is largerthan the fixed value, the HDD 1 determines to use a partial continuousspace (S17). When the data length is equal to or smaller than the fixedvalue, the HDD 1 determines to use the read buffer 241 as a whole (S15).

Further, for the case of sequential read, the HDD 1 uses a partialcontinuous space to read data from the magnetic disk 11. For the case ofsequential read, the data read is sequentially transferred together withback data to the host 51. With such an arrangement, by using thesub-buffer 412 and overwriting the transferred data with new read data,it is possible to reduce the amount of existing cache data to be erased,thus improving the cache hit rate. Here, the sequential read shall implya read process of data that is sequential to read data addresses of theprevious read command, or a read command thereof.

For the case of sequential read, the read data thereof is in some casescontained in the back data BD that was already read before from themagnetic disk 11. For example, when data is read from the magnetic disk11 in accordance with the previous read command of the sequential readcommand, read data of the current sequential read is contained in theback data. Consequently, for the case of sequential read, data is readfrom the magnetic disk 11 when the read data is not contained in theback data that was already read from the magnetic disk 11.

Hereinafter, an example of a process by the HDD 1 to determine a methodof using the read buffer 241 for the case of sequential read will bedescribed with reference to FIG. 7. In step S21, upon receiving a readcommand, the HDD 1 judges whether or not the associated read data isstored in the read buffer 241 (cache hit judgment) (S22). For the caseof a cache hit judgment (YES in step S22), the HDD 1 transfers data inthe read buffer 241 to the host 51 (S23). When associated read data isnot stored in the read buffer 241 (NO in step S22), the HDD 1 judgeswhether or not the read command is sequential read (S24). When thecommand is not sequential read (NO in step S24), the HDD 1 determines amethod for using the buffer based on data length (S25). When the commandis sequential read (YES in S24), the HDD 1 determines use of a partialcontinuous space (S26).

When data is read from the magnetic disk 11 for sequential reading, theHDD 1 uses a partial continuous space. The HDD 1 can use a partialcontinuous space of either mode described by referring to in FIG. 4 orFIG. 5. For example, when a higher priority is given to existing cachedata, or to make control thereof easier, the HDD 1 selects a bufferconfiguration wherein the partial continuous space 411 and thesub-buffer 412 can coincide with each other as shown in FIG. 4. On theother hand, when it is preferable to leave and keep the front data ascache data, it is possible to achieve buffer control by using the modeshown in FIG. 5.

When using only part of the continuous space, the HDD 1 defines thespace in the read buffer 241 and further defines a sub-buffer within thedefined space. The write start position (leading-end position) of thepartial continuous space can be set at the trailing-end position or thewrite end position of data previously written from the magnetic disk 11in order to facilitate control of the buffer. Alternatively, to improvethe cache hit rate, it is possible to set the write start position ofthe partial continuous space in the space in which cache data having lowpriority is stored. The priority can be determined based on, forexample, access frequency to the data from the host 51, or recordingorder of cache data in the read buffer 241 indicating that the data isold or new.

With the embodiment, the HDC/MPU 23 executes the above-stated control ofthe read buffer 241. To this end, read buffer control of the HDC/MPU 23will be described hereunder in detail. FIG. 8 is a block diagram showinga configuration related to control of the read buffer 241 in the HDD 1.The HDC/MPU 23 includes, as a hardware configuration, a host interface231, a drive interface 232 and a memory manager 233. As a microcodeoperates on an MPU, the MPU can function as a host interface manager234, a command execution manager 235 and a cache manager 236. Likewise,a memory RAM 24 can function as the read buffer 241 and the cache table242 by temporarily storing a command and data.

The host interface 231 executes actual data transfer processing with thehost 51, thereby functioning as a data transfer unit. The driveinterface 232 executes actual I/O data processing with the magnetic disk11 (or the R/W channel 21). The memory manager 233 controls data memoryof the RAM (memory) 24 and executes intermediate processing of variousdata between the other function blocks in the HDC/MPU 23 and the RAM 24.

The host interface manager 234 functions as a data transfer control unitthat manages the host interface 231 and sends or receives a prescribednotification or a command to and from the host interface 231. The cachemanager 236 sets a read pointer RP and a write pointer WP of the readbuffer 241 by referring to the cache table 242. Further, the cachemanager 236, when using a partial continuous space in the read buffer241, executes setups of the partial continuous space and the sub-buffer.The command execution manager 235 controls execution of a commandaccording to an instruction from the cache manager 236. Further, thecommand execution manager 235 controls data writing and data reading toand from the magnetic disk 11 by controlling the driver interface 232.

Here, it should be noted that information on data stored in the readbuffer 241 is registered in the cache table 242. More specifically,identification numbers, LBAs, data lengths, start positions (addresses)in the read buffer 241, etc. for respective data are registered as shownin FIG. 9. Here, each data can be registered, for example, in the mannerthat a series of addresses having sequential LBA are registered as onedata unit. Referring to the example shown in FIG. 5, each of theabove-stated information is registered in the cache table 242 for eachof the front data FD and back data BD that are written anew. Inaddition, information such as the order that each data is recorded inthe read buffer 241 and the number of times of cache hit in the past canbe registered in the cache table.

Next, a control sequence of the read buffer 241 will be described withreference to a flow chart shown in FIG. 10. In step S31 in FIG. 10, whenthe host interface 231 receives a read command from the host 51, theread command is transferred to the cache manager 236. The cache manager236, upon receiving the read command, judges whether or not therequested read data exists in the read buffer 241 by referring to thecache table (S32).

For the case of a cache hit judgment (YES in step S32), the cache hitmanager 236 instructs the command execution manager 235 to execute readprocessing by designating the address and the data length of the readdata to be read from the read buffer 241. The command execution manager235 sets the read pointer and the data length in the register of thememory manager 233 and instructs the memory manager 233 to read the readdata. The memory manager 233, responding to the instruction, reads theread data from the read buffer 241 and transfers the read data to thehost 51 via the host interface 231 (S33).

When the read data does not exist in the read buffer 241 (NO in stepS32), the cache manager 236 determines whether the read buffer 241should be used as a whole or part of continuous space thereof for thedata to be read from the magnetic disk 11 (S34). With such anarrangement, the cache manager 236 can determine a method for using theread buffer 241 in accordance with the above-stated judgment criteria.

When it is determined that the read buffer 241 is used as a whole (NO instep S34), the cache manager 236 instructs the command execution manager235 to write the data read from the magnetic disk 11 to the read buffer241 by designating the LBA range of data to be read from the magneticdisk 11, use of the read buffer 241 as a whole, and the write pointerposition of the read buffer 241. The command execution manager 235 setsthe information designated by the cache manager 236 in each register ofthe memory manager 233 and the drive interface 232. The drive interface232 and the memory manager 233 record the data read from the magneticdisk 11 in the read buffer 241 according to the information set in theregister (S35).

The command execution manager 235, upon acquiring information on thedata length of front data from the drive interface 232, sets a readpointer in the memory manager 233 to transfer read data to the host 51.The memory manager 233, according to the read pointer thus set, readsthe read data from the read buffer 241 and transfer the data to the host51 (S36). Further, the information on front data is transferred to thecache manager 236, which then updates the cache table 242 by using theinformation on the front data and the information that has been alreadyacquired.

When it is determined that only part of the continuous space of the readbuffer 241 (YES in step S34), the cache manager 236 instructs thecommand execution manager 235 to write the data read from the magneticdisk 11 to the read buffer 241 by designating the LBA range of data tobe read from the magnetic disk 11, the leading-end position and thetrailing-end position of the partial continuous space, and theleading-end position and the trailing-end position of the sub-buffer(S37). Now, here, the write pointer position of the read buffer 241 willcoincide with the leading-end position of the partial continuous space.The cache manager 236 thus can determine the leading-end position andthe trailing-end position of each of partial continuous space and thesub-buffer.

The command execution manager 235 sets the information designated by thecache manager 236 in each register of the memory manager 233 and thedrive interface 232. The drive interface 232 and the memory manager 233record the data read from the magnetic disk 11 in the read buffer 241according to the information set in the register. At this time, thememory manager 233 stores the data in the partial continuous space andthe sub-buffer located therein (S38).

The command execution manager 235, upon acquiring information on thedata length of front data from the drive interface 232, sets a readpointer in the memory manager 233 to transfer read data to the host 51.The memory manager 233, according to the read pointer thus set, readsthe read data from the read buffer 241 and transfers the data to thehost 51 (S36). Further, the information on front data is transferred tothe cache manager 236, which then updates the cache table 242 by usingthe information on the front data and the information that was alreadyacquired.

The description stated above is made just to explain embodimentsaccording to the present invention, and therefore, the present inventionis not limited to the above-stated embodiments. It is understood bythose skilled in the art that elements of the foregoing embodiments canbe easily changed, added or modified without departing from the spiritand scope thereof. For example, the write buffer control according tothe embodiment can be applied to a data storage device that uses arecording medium other than a magnetic disk. Further, the buffer controlaccording to the present invention can be applied to an HDD which doesnot perform prefetching or pre-reading as well as to an HDD whichperforms only prefetching or only pre-reading. Although it is preferablethat the data storage device should include a read buffer and a writebuffer independently, the buffer control according to the presentinvention can be applied to a buffer which stores both of write data andread data.

It is to be understood that the above description is intended to beillustrative and not restrictive. Many embodiments will be apparent tothose of skill in the art upon reviewing the above description. Thescope of the invention should, therefore, be determined not withreference to the above description, but instead should be determinedwith reference to the appended claims along with their full scope ofequivalents.

1. A data storage device that transmits read data read from a recordingmedium to a host, said data storage device comprising: a buffer having aleading end and a trailing end coupled to each other and enablingcontinuous recording of data from a write start position designated by apointer; and a controller configured to control data recording to thebuffer; wherein the controller: determines whether the buffer should beused as a whole or a part of continuous space of the buffer should beused to read the read data from the recording medium; specifies, ifusing the part of continuous space is determined, a sub-buffer which isa continuous space formed by coupling a leading-end position and atrailing-end position to each other; and executes writing of data fromthe recording disk to the sub-buffer in parallel with reading of theread data to the host.
 2. A data storage device according to claim 1,wherein said sub-buffer and said part of continuous space coincides witheach other.
 3. A data storage device according to claim 2, wherein thedata to be read from said recording medium contains, in addition to readdata to said host, back data that is stored in a back position of theread data in said recording medium, and a capacity of said sub-buffercoincides with a data length of said back data.
 4. A data storage deviceaccording to claim 1, wherein the data to be read from said recordingmedium contains, in addition to read data to said host, back data thatis stored in a back position of the read data in said recording medium,and a capacity of said sub-buffer is smaller than data to be read fromsaid recording medium and is larger than a data length of said backdata.
 5. A data storage device according to claim 1, wherein the data tobe read from said recording medium contains, in addition to read data tosaid host, back data that is stored in a back position of the read datain said recording medium, and a capacity of said sub-buffer coincideswith a data length of said back data.
 6. A data storage device accordingto claim 1, wherein the data to be read from said recording mediumcontains, in addition to read data to said host, back data that isstored in a back position of the read data in said recording medium aswell as the front data that is stored in a front position of the readdata in said recording medium; a capacity of said sub-buffer exceeds adata length of said back data; said front data is written in a frontspace of said sub-buffer; and said back data is written after the readdata is written in said sub-buffer.
 7. A data storage device accordingto claim 1, wherein said data storage device includes a write buffer tostore write data from said host, in addition to said buffer to storedata from said recording disk.
 8. A data storage device according toclaim 1, wherein said controller determines to use said part ofcontinuous space when an expected data length of data to be read fromsaid recording medium is larger than a reference value.
 9. A datastorage device according to claim 8, wherein the data to be read fromsaid recording medium contains read data to said host, back data whichis stored in succession to a back position of the read data in saidrecording medium as well as the front data that is stored in a frontposition of the read data in said recording medium.
 10. A data storagedevice according to claim 8, wherein said reference value is apredetermined fixed value and the value is chosen among valuesindicating about 50% or over of a capacity of said buffer.
 11. A datastorage device according to claim 1, wherein said controller determinesto use said part of continuous space when an expected data length ofdata to be read from said recording medium is larger than a capacity ofsaid buffer.
 12. A data storage device according to claim 1, whereinsaid controller determines to use said part of continuous space when anexpected data length of data read from said recording medium is largerthan a capacity of said continuous free space located next to an endposition of previous data writing to said buffer and the data length islarger than a reference value.
 13. A data storage device according toclaim 1, wherein said controller uses the fact that a command associatedwith said read data is sequential read as one of criteria fordetermining the use of said part of continuous space in said buffer. 14.A data storage device according to claim 1, wherein said data storagedevice reads back data stored in a back position of the read data insaid recording medium together with read data to be transmitted to saidhost from said recording disk; and wherein said controller determines,when at least part of read data of sequential read is not contained inback data at the time of previous data reading from a recording disk, touse the part of continuous space in said buffer for reading the readdata of the sequential read from said recording disk.
 15. A controlmethod of a data storage device which includes a buffer having a leadingend and a trailing end coupled to each other and enabling continuousrecording of data from a write start position as designated by apointer, the method comprising: receiving a read command from a host;determining reading read data associated with said read command from arecording medium; determining whether the buffer should be used as awhole or a part of continuous space in the buffer should be used tostore data, including said read data, read from said recording medium;writing data, when it is determined to use said part of continuousspace, from said recording medium to a sub-buffer which is a continuousspace formed by coupling a leading-end position and a trailing-endposition to each other as defined within the part of continuous space;and in parallel with the data writing to said sub-buffer, reading saidread data from the sub-buffer to said host.
 16. A control method of adata storage device according to claim 15, wherein it is determinedwhether said buffer should be used as a whole or a part of continuousspace in said buffer is used, based on data length of data to be readfrom said recording medium.
 17. A control method of a data storagedevice according to claim 15, wherein the data to be read from saidrecording medium contains, in addition to the read data to said host,back data stored in a back position of the read data in said recordingmedium, and a capacity of said sub-buffer should coincides with a datalength of said back data.
 18. A control method of a data storage deviceaccording to claim 15, wherein the data to be read from said recordingmedium contains, in addition to the read data to said host, back datastored in a back position of the read data in said recording medium andfront data stored in a front position of the read data in said recordingmedium; and wherein a capacity of said part of continuous space is atleast a value which is the sum of a data length of said back data and adata length of said front data.
 19. A control method of a data storagedevice according to claim 15, wherein the data to be read from saidrecording medium contains, in addition to read data to said host, backdata that is stored in a back position of the read data in saidrecording medium as well as the front data that is stored in a frontposition of the read data in said recording medium; a capacity of saidsub-buffer exceeds a data length of said back data; said front data iswritten in a front space of said sub-buffer; and said back data iswritten after the read data is written in said sub-buffer.
 20. A controlmethod of a data storage device according to claim 15, furthercomprising: determining to use said part of continuous space when anexpected data length of data to be read from said recording medium islarger than a reference value.